//
//  FeedbackViewModel.m
//  GLGW_Shoping
//
//  Created by yang on 2018/12/1.
//  Copyright © 2018年 yang. All rights reserved.
//

#import "FeedbackViewModel.h"

@interface FeedbackViewModel ()<UITextViewDelegate>
{
    GLGWTextView * angerTextView;
    GLGWButton * confirmSubmitBut;
}
@end

@implementation FeedbackViewModel

-(instancetype)initWithViewToViewScrollView:(UIScrollView *)scrollView theSuperView:(UIView *)superView{
    if (self = [super initWithViewToViewScrollView:scrollView theSuperView:superView]) {
        scrollView.y = scrollView.y + kHeightProportion_In_iPhoneTriploid(10);
        scrollView.height = scrollView.height - kHeightProportion_In_iPhoneTriploid(10);
        [superView addSubview:scrollView];
        //
        angerTextView = [[GLGWTextView alloc] initWithFrame:CGRectMake(kWidthProportion_In_iPhoneTriploid(15), kHeightProportion_In_iPhoneTriploid(20), KScreenWidth - kWidthProportion_In_iPhoneTriploid(30), kHeightProportion_In_iPhoneTriploid(140)) fontType:SYSTEMFONT(14) colorType:kColor_Rule_Black inSuperView:scrollView];
        angerTextView.backgroundColor = [UIColor colorWithHexString:@"#F2F2F2"];
        angerTextView.delegate = self;
        angerTextView.placeholderAttributes = @{NSFontAttributeName:[UIFont systemFontOfSize:14],NSForegroundColorAttributeName:[UIColor colorWithHexString:@"#C9C9C9"]};
        angerTextView.placeholder = @"留下您宝贵的建议，帮助我们不断改善钢来钢网，为您提供更好地服务";
        //
        confirmSubmitBut = [[GLGWButton alloc] initWithFrame:CGRectMake(kWidthProportion_In_iPhoneTriploid(30), kY_With_View(angerTextView, 60), KScreenWidth - kWidthProportion_In_iPhoneTriploid(60), kHeightProportion_In_iPhoneTriploid(44)) hTitle:@"确认提交" titleLableFont:SYSTEMFONT(16) titleLableColor:[UIColor whiteColor] theCornerRadius:kHeightProportion_In_iPhoneTriploid(22) backgroundColr:[UIColor colorWithHexString:@"#CCCCCC"] inSuperView:scrollView];
        confirmSubmitBut.enabled = NO;
        [confirmSubmitBut addTarget:self action:@selector(submitAction) forControlEvents:UIControlEventTouchUpInside];
        
    }
    return self;
}
-(void)submitAction{
    DLog(@"------      %@",angerTextView.text);
}
#pragma mark =================== UITextViewDelegate ===================
-(void)textViewDidChange:(UITextView *)textView{
    if (textView.text.length >0) {
        confirmSubmitBut.backgroundColor = kColor_Rule_Yellow;
        confirmSubmitBut.enabled = YES;
    }else{
        confirmSubmitBut.backgroundColor = [UIColor colorWithHexString:@"#CCCCCC"];
        confirmSubmitBut.enabled = NO;
    }
}

@end
